{extend name="base" /}
{block name="body"}
<div class="layui-body">
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class=""><a href="{:url('admin/article/index2')}">医院文章管理</a></li>
            <li class="layui-this">添加医院文章</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <form class="layui-form form-container" action="{:url('admin/article/addHospital')}" method="post">
                    <div class="layui-form-item">
                        <label class="layui-form-label">所属栏目</label>
                        <div class="layui-input-block">
                            <select name="cid" lay-verify="required">
                                {foreach name="category_level_list" item="vo"}
                                <option value="{$vo.id}">{neq name="vo.level" value="1"}|{php}for($i=1;$i<$vo['level'];$i++){echo ' ----';}{/php}{/neq} {$vo.name}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">标题</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" value="" required  lay-verify="required" placeholder="请输入标题" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">标题英文</label>
                        <div class="layui-input-block">
                            <input type="text" name="english" value="" placeholder="（选填）请输入标题英文" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">副标题</label>
                        <div class="layui-input-block">
                            <input type="text" name="vice_title" value="" placeholder="（选填）请输入副标题" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">所在城市</label>
                        <div class="layui-input-block">
                            <input type="text" name="city" value="" placeholder="（选填）请输入所在城市" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">印象</label>
                        <div class="layui-input-block">
                            <input type="text" name="impression" value="" placeholder="（选填）请输入印象 用|隔开 例如:  朱总|世界第一" class="layui-input">
                        </div>
                    </div>
                    
                    <div class="layui-form-item">
                        <label class="layui-form-label">缩略图</label>
                        <div class="layui-input-block">
                            <input type="text" name="thumb" value="" placeholder="请上传缩略图" class="layui-input layui-input-inline" id="thumb">
                            <input type="file" name="file" class="layui-upload-file">
                        </div>
                    </div>
<!--                    <div class="layui-form-item">
                        <label class="layui-form-label">地图坐标</label>
                        <div class="layui-input-block">
                            <input type="text" name="coordinates" value="" placeholder="（选填）请输入坐标" class="layui-input layui-input-inline">
                            <a class="layui-btn" target="_blank" href="http://api.map.baidu.com/lbsapi/getpoint/index.html">点击去拾取坐标 然后记得把右上角的坐标填回来！</a>
                        </div>
                    </div>-->
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">建院时间</label>
                            <div class="layui-input-block">
                                <input type="text" style='width: 283px;' name="time" value="" placeholder="（选填）请输入建院时间  例如:1987年" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">医院性质</label>
                            <div class="layui-input-inline">
                                <input type="text" style='width: 283px;' name="nature" value="" placeholder="（选填）请输入医院性质  例如:公立医院" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">医院类型</label>
                            <div class="layui-input-block">
                                <input type="text" style='width: 283px;' name="type" value="" placeholder="（选填）请输入医院类型  例如:综合医院" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">医院地址</label>
                            <div class="layui-input-inline">
                                <input type="text" style='width: 283px;' name="addr" value="" class="layui-input">
                            </div>
                        </div>
                    </div>
                    
                    
                    <div class="layui-form-item">
                        <label class="layui-form-label">简介</label>
                        <div class="layui-input-block">
                            <textarea name="introduction" role="5" rows="10" placeholder="（选填）请输入简介" class="layui-textarea"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">地理位置</label>
                        <div class="layui-input-block">
                            <textarea name="geographic" placeholder="（选填）请输入地理位置" class="layui-textarea"></textarea>
                        </div>
                    </div>
                    
                    
                   <fieldset class="layui-elem-field">
                       <legend>附近景色</legend>
                       <div class="layui-field-box" id='js'>
                           <div class="layui-form-item js">
                                <label class="layui-form-label">景色图</label>
                                <div class="layui-input-block">
                                    <input type="text" name="scenery[img][]" value="" placeholder="请上传景色图" class="layui-input layui-input-inline" id="scenery">
                                    <input type="file" name="file" class="layui-upload-file">
                                </div>
                                </br>
                                <div class="layui-inline">
                                    <label class="layui-form-label">标题</label>
                                    <div class="layui-input-block">
                                        <input type="text" style='width: 260px;' name="scenery[title][]" value="" placeholder="（选填）请输入景色标题" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">简介</label>
                                    <div class="layui-input-block">
                                        <textarea name="scenery[intor][]" placeholder="（选填）请输景色简介" class="layui-textarea"></textarea>
                                    </div>
                                </div>
                            </div>
                       </div>
                   </fieldset>
                    <div class="layui-form-item">
                        <label class="layui-form-label">排序</label>
                        <div class="layui-input-block">
                            <input type="text" name="sort" value="0" required  lay-verify="required" class="layui-input">
                        </div>
                    </div>
                   
                    <div class="layui-form-item">
                        <label class="layui-form-label">是否热门</label>
                        <div class="layui-input-block">
                            <input type="radio" name="is_hot" value="1" title="是">
                            <input type="radio" name="is_hot" value="0" title="否" checked="checked">
                        </div>
                    </div>
                    
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="*">保存</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            <div class="layui-btn layui-btn-normal addj">新增一个景色</div>
                            <div class="layui-btn layui-btn-danger del">删除一个景色</div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script>
$(function(){
    $('.addj').on('click',function(){
        var js = $('.js:first').clone();
        $(js).find('input,textarea').val('');
        $('#js').append(js);
    })
    $('.del').on('click',function(){
        if($('.js').length >1)
            $('.js:last').remove();
    })
    
    
    $('body').on('click','.layui-upload-file',function(){
        layui.upload({
            url: "/index.php/api/upload/upload",
            type: 'image',
            ext: 'jpg|png|gif|bmp|jpeg',
            success: function (data,input) {
                if (data.error === 0) {
                    $(input).parents('.layui-input-block').find('input').val(data.url);
                } else {
                    layer.msg(data.message);
                }
            }
        });
    })
    
}) 
</script>
{/block}